package com.csjbot.weedle_auto.view

import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent

/**
 * author : chenqi.
 * e_mail : 1650699704@163.com.
 * create_time : 8/15/17.
 */

class CustomViewPagerView : ViewPager {
    private var preX = 0

    constructor(context: Context) : super(context) {}

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}

    override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
        if (ev.action == MotionEvent.ACTION_DOWN) {
            preX = ev.x.toInt()
        } else {
            val egX = ev.x.toInt() - preX
            if (Math.abs(egX) > 10) {
                return true
            } else {
                preX = ev.x.toInt()
            }
        }
        return super.onInterceptTouchEvent(ev)
    }
}
